/**
 * 
 */
package sk.lukaskrupa.guess.the.color.listeners;

import sk.lukaskrupa.guess.the.color.logging.Logging;
import sk.lukaskrupa.guess.the.color.ui.Menu;
import sk.lukaskrupa.guess.the.color.ui.R;
import android.view.View;
import android.view.View.OnClickListener;

/**
 * Listen to Menu activity buttons.
 * 
 * @author Lukas Krupa (lukas0krupa@gmail.com)
 * 
 */
public class MenuButtonListener implements OnClickListener {

	private static final Logging logger = Logging.getLog(MenuButtonListener.class);

	private final Menu menu;

	/**
	 * Constructs listener and save reference to Menu activity
	 * 
	 * @param menu
	 *            view that executed listener
	 * @param appSettings
	 *            to use
	 */
	public MenuButtonListener(Menu menu) {
		this.menu = menu;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void onClick(View v) {

		logger.debug("onClick", "You clicked on button with ID=" + v.getId());
		if (v.getId() == R.id.newGame) {

			logger.info("onClick", "Creating new Game.");
			this.menu.startGame();
		} else if (v.getId() == R.id.settings) {

			logger.info("onClick", "Opening settings.");
			this.menu.startSettings();
		} else if (v.getId() == R.id.help) {

			logger.info("onClick", "Opening help.");
			this.menu.startHelp();
		} else if (v.getId() == R.id.exit) {

			logger.info("onClick", "Exiting game.");
			this.menu.finish();
		}
	}
}
